package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by rhb on 2016/5/12.
 */
public class BisaibaomingTask extends CouponHttpBaseTask{
    private String mGameId;
    private String mPhone;
    private String vfCode;
    private String mNick;
    private boolean mSex;
    private String mAge;
    private String userSign;
    private String userLogo;
    private int needCode;
    private String mSchool;
    public BisaibaomingTask(String gameId,String phoneNum,String code,String nickname,boolean sex,String age,String sign,String headLogo,int need,String school) {
        super(TaskType.BISAIBAOMING_TASK);
        mGameId = gameId;
        mPhone = phoneNum;
        vfCode = code;
        mNick = nickname;
        mSex = sex;
        mAge = age;
        userSign = sign;
        userLogo = headLogo;
        needCode = need;
        mSchool = school;
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT){
            CouponHttpRequest request = new CouponHttpRequest(RequestType.BISAIBAOMING_REQUEST);
            JSONObject json = new JSONObject();
            json.put("phoneNum",mPhone);
            json.put("sex",mSex);
            json.put("vfCode",vfCode);
            json.put("nickName",mNick);
            json.put("age",mAge);
            json.put("userSign",userSign);
            json.put("userLogo",userLogo);
            json.put("gameId",mGameId);
            json.put("needVerifyCode",needCode);
            json.put("school",mSchool);
            request.setData(json.toJSONString());
            request.setApiNo(ApiNo.BISAIBAOMING);
            addRequest(request);
        }
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS,response.getBody());
    }
}
